<?php


namespace app\admin\struct;


trait PersonStruct
{
    /**
     * 员工结构体
     * @param array $request
     * @return int[]
     * @author ran
     * @date 2021-09-16 16:35
     * mailbox 466180170@qq.com
     */
    public function createPersonResourceStruct(array $request): array
    {
        return [
            'name' => (string)$request['name'],
            'shop_id' => (int)$request['shopId'],
            'sex' => (string)$request['sex'],
            'job_age' => (int)$request['jobAge'],
            'age' => (int)$request['age'],
            'station_id' => (int)$request['stationId'],
            'station_name' => (string)$request['stationName'],
            'position_id' => (int)$request['positionId'],
            'position_name' => (string)$request['positionName'],
            'phone' => (string)$request['phone'],
            'leave_at' => (string)$request['leaveAt'],
            'entry_at' => (string)$request['entryAt'],
            'status' => (string)$request['status'],
            'birthday' => (string)$request['birthday'],
            'probation' => (int)$request['probation'],
            'reason' => (string)$request['reason'],
        ];
    }

    /**
     * @param $arr
     * @param array $needApiExceptKey
     * @return array
     * @author ran
     * @date 2021-10-18 21:59
     * mailbox 466180170@qq.com
     */
    public function returnShopResourceStructList($arr, array $needApiExceptKey = []): array
    {
        $apiArr = [];
        foreach ($arr as $value) {
            $apiArr[] =
                [
                    'name' => $value['name'],
                    'shopId' => $value['shop_id'],
                    'age' => $value['age'],
                    'jobAge' => $value['job_age'],
                    'sex' => $value['sex'],
                    'stationId' => $value['station_id'],
                    'stationName' => $value['station_name'],
                    'positionId' => $value['position_id'],
                    'positionName' => $value['position_name'],
                    'phone' => $value['phone'],
                    'leaveAt' => $value['leave_at'],
                    'entryAt' => $value['entry_at'],
                    'status' => $value['status'],
                    'birthday' => $value['birthday'],
                    'probation' => $value['probation'],
                    'reason' => $value['reason'],
                ];
        }
        return exceptMoreArrKey($apiArr, $needApiExceptKey);
    }
}